Carriage return

Carriage return, often shortened to CR or return, refers to a control character or mechanism used to start a new line of text.

Originally, the term "carriage return" referred to a mechanism or lever on a typewriter. It was used after typing a line of text and caused the assembly holding the paper (the carriage) to return to the right (assuming a left-to-right language), so the machine was ready to type again on the left side of the paper. The lever would also usually advance the paper to the next line. The first power carriage return was added to electric typewriters by Smith Corona in 1960. The key for this was usually labeled "carriage return" or "return". With typewriters like the Selectric, where the type element was moved when typing and the paper held stationary, the key returned the type element to the left and the term "carrier return" was sometimes used for this function.

To improve the keyboard for non-English-speakers, the symbol (U+21B5) was introduced to mark this key, since this graphic could communicate the action of the key without using words.

Computers

In computing, the carriage return (CR) is one of the control characters in ASCII code, Unicode, EBCDIC, or many other codes. It commands a printer or other sort of output system such as a display to move the position of the cursor to the first position on the same line. It was mostly used along with line feed (LF), a move to the next line, so that together they start a new line. Together, this sequence can be referred to as CRLF.

The carriage return and line feed functions were split for two reasons:

As early as 1901 Baudot code contained separate carriage return and line feed characters.

Many computer programs use the carriage return character, alone or with a line feed, to signal the end of a line of text, but other characters are also used for this function (see newline); others use it only for a paragraph break (a hard return). Some standards which introduce their own representations for line and paragraph control (for example HTML) and many programming languages treat carriage return and line feed as whitespace.

In ASCII and Unicode, the carriage return is defined as 13 (or hexadecimal 0D); it may also be seen as control+M or ^M. In the C programming language, and many other languages influenced by it, \r denotes this character.[1]

See also

References

  1. ^ Eric S. Roberts. The Art and Science of C. Addison-Wesley, 1995. p311.